Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/model/src/commonMain/kotlin/org/meshtastic/core/model/DeviceVersion.kt 01cd54907d62cd90913d3d071b6bc240cae365ef (01cd5490) Text, 3.28 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.model

Tff7b72import T7ee787kotlin.jvm.JvmInline

T8b949e/** Outcome of checking a device's firmware version against the app's minimum requirements. */
Tff7b72enum Tff7b72class T56d364FirmwareCheckStatus Tb4b4b4{
T8b949e/** Firmware meets the recommended minimum. */
Te6edf3OKTb4b4b4,

T8b949e/** Firmware is usable but below the recommended minimum; the user should be nudged to update. */
Te6edf3SHOULD_UPDATETb4b4b4,

T8b949e/** Firmware is below the absolute minimum the app supports. */
Te6edf3TOO_OLDTb4b4b4,

T8b949e/** The version string could not be parsed (e.g. a blank/transient value during connection). Status is unknown. */
Te6edf3UNKNOWNTb4b4b4,
Tb4b4b4}

T8b949e/** Zero-overhead wrapper providing structured access to parse and compare device version strings. */
Tf0883e@JvmInline
Tff7b72value Tff7b72class T56d364DeviceVersionTb4b4b4(Tff7b72val Te6edf3asStringTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4: Te6edf3ComparableTff7b72<Te6edf3DeviceVersionTff7b72> Tb4b4b4{

T8b949e/** The integer representation of the version (e.g., 2.7.12 → 20712). */
Tff7b72val Te6edf3asIntTb4b4b4: Tffa657Int
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3parseVersionTb4b4b4(Te6edf3asStringTb4b4b4)

T8b949e/** True when the version string parsed to a real version (non-zero). */
Tff7b72val Te6edf3isValidTb4b4b4: Tffa657Boolean
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3asInt Tff7b72> T79c0ff0

T8b949e/**
* Classify this version against the app's firmware requirements.
*
* An unparseable version (int 0) is [FirmwareCheckStatus.UNKNOWN], NOT [FirmwareCheckStatus.TOO_OLD] — a transient
* or garbled version string arriving mid-handshake must never be mistaken for ancient firmware (regression #3726).
*/
Tff7b72val Te6edf3checkStatusTb4b4b4: Te6edf3FirmwareCheckStatus
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72=
Tff7b72when Tb4b4b4{
Tff7b72!Te6edf3isValid Tff7b72-Tff7b72> Te6edf3FirmwareCheckStatusTb4b4b4.Te6edf3UNKNOWN
Tff7b72this Tff7b72< Te6edf3DeviceVersionTb4b4b4(Te6edf3ABS_MIN_FW_VERSIONTb4b4b4) Tff7b72-Tff7b72> Te6edf3FirmwareCheckStatusTb4b4b4.Te6edf3TOO_OLD
Tff7b72this Tff7b72< Te6edf3DeviceVersionTb4b4b4(Te6edf3MIN_FW_VERSIONTb4b4b4) Tff7b72-Tff7b72> Te6edf3FirmwareCheckStatusTb4b4b4.Te6edf3SHOULD_UPDATE
Tff7b72else Tff7b72-Tff7b72> Te6edf3FirmwareCheckStatusTb4b4b4.Te6edf3OK
Tb4b4b4}

Tff7b72override Tff7b72fun Td2a8ffcompareToTb4b4b4(Te6edf3otherTb4b4b4: Te6edf3DeviceVersionTb4b4b4)Tb4b4b4: Tffa657Int Tff7b72= Te6edf3asIntTb4b4b4.Te6edf3compareToTb4b4b4(Te6edf3otherTb4b4b4.Te6edf3asIntTb4b4b4)

Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72const Tff7b72val Te6edf3MIN_FW_VERSION Tff7b72= Ta5d6ff"Ta5d6ff2.5.14Ta5d6ff"
Tff7b72const Tff7b72val Te6edf3ABS_MIN_FW_VERSION Tff7b72= Ta5d6ff"Ta5d6ff2.3.15Ta5d6ff"

Tff7b72private Tff7b72val Te6edf3VERSION_REGEX Tff7b72= Te6edf3RegexTb4b4b4(Ta5d6ff"Ta5d6ff(Ta5d6ff\\Ta5d6ffd{1,2})Ta5d6ff\\Ta5d6ff.(Ta5d6ff\\Ta5d6ffd{1,2})Ta5d6ff\\Ta5d6ff.(Ta5d6ff\\Ta5d6ffd{1,2})Ta5d6ff"Tb4b4b4)

T8b949e/**
* Convert a version string of the form 1.23.57 to a comparable integer (12357). Returns 0 for unparseable
* strings.
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffMagicNumberTa5d6ff"Tb4b4b4)
Tff7b72private Tff7b72fun Td2a8ffparseVersionTb4b4b4(Te6edf3sTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3versionString Tff7b72= Tff7b72if Tb4b4b4(Te6edf3sTb4b4b4.Te6edf3count Tb4b4b4{ Tffa657it Tff7b72=Tff7b72= Ta5d6ff'.' Tb4b4b4} Tff7b72=Tff7b72= T79c0ff1Tb4b4b4) Ta5d6ff"Tffd700$Te6edf3sTa5d6ff.0Ta5d6ff" Tff7b72else Te6edf3s
Tff7b72val Te6edf3match Tff7b72= Te6edf3VERSION_REGEXTb4b4b4.Te6edf3findTb4b4b4(Te6edf3versionStringTb4b4b4) Tff7b72?: Tff7b72return T79c0ff0
Tff7b72val Tb4b4b4(Te6edf3majorTb4b4b4, Te6edf3minorTb4b4b4, Te6edf3buildTb4b4b4) Tff7b72= Te6edf3matchTb4b4b4.Te6edf3destructured
Tff7b72return Te6edf3majorTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Tff7b72* T79c0ff1T79c0ff0T79c0ff0T79c0ff0T79c0ff0 Tff7b72+ Te6edf3minorTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Tff7b72* T79c0ff1T79c0ff0T79c0ff0 Tff7b72+ Te6edf3buildTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s